package com.tuanzi.loan.web.bean.distribution;

import com.tuanzi.loan.business.service.family.DistributionRecordService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.web.configuration.JSFListingBean;

import com.tuanzi.loan.vo.request.distribution.DistributionRecordSearchRequest;
import com.tuanzi.loan.vo.response.distribution.GalaxyCardDistributionRecordSearchResponse;
import com.tuanzi.loan.web.lazy.distribution.DistributionRecordDataModel;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.faces.bean.ViewScoped;
import java.util.Map;

/**
 * 邀请明细统计
 * @author JinRuiyang 2018/2/7 15:29:29
 */
@Debug
@Data
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class DistributionRecordBean extends JSFListingBean<DistributionRecordSearchRequest, GalaxyCardDistributionRecordSearchResponse> {

    @Autowired
    private DistributionRecordService service;

    private Map<String, Integer> channelList;
    private Map<String, Integer> productList;
    private Map<String, String> platformList;
    private Map<String, Long> distributionActivityList;

    @PostConstruct
    private void init() {
        initLazyDataModel();
        channelList = service.getChannelList();
        productList = service.getProductList();
        platformList = service.getPlatformList();
        distributionActivityList = service.getDistributionActivity();
    }

    public void onReset() {
        initLazyDataModel();
    }

    public void onRefresh(){
        lazyDataModel = new DistributionRecordDataModel($);
        addSuccessfullyMessage();
    }

    private void initLazyDataModel() {
        $ = new DistributionRecordSearchRequest();
        lazyDataModel = new DistributionRecordDataModel($);
    }
}